<?php
class GridFactory implements Factory{
	const SEPERATOR = '_';
	/**
	 * (non-PHPdoc)
	 * @see library/Factory/Factory::getInstance()
	 * @param ControllerRoute $route
	 * @return Controller
	 */
	public function getInstance($route){
		return null;
	}
	/**
	 * Get Entity by Class ...
	 * @param string $context
	 * @return BaseEntity
	 */
	public static function instance($context){
		return null;
	}
/**
	 * Get Form by Class Name.
	 * @param string $context
	 * @return BaseGrid
	 */
	public static function minstance($context,$module){
		$formPath = Configuration::APPLICATION_FOLDER
		. SLASH
		. $module
		. SLASH
		. Configuration::GRID_FOLDER
		. SLASH
		. $context .'.php';
		$class = $module . GridFactory::SEPERATOR . $context . GridFactory::SEPERATOR . BaseGrid::FORM_SURFIX;
		if(file_exists($formPath)){
			include_once $formPath;
			if(!class_exists($class)){
				Log::error("FormFactory", "Class " . $class . " Not found");
				if(Configuration::DEBUG_MOD)
				throw new ModelException("Class " . $class . " Not found");
				return new BaseGrid();
			}
			return new $class;
		}
		else {
			Log::error("FormFactory", "File " . $formPath . " Not found");
			if(Configuration::DEBUG_MOD)
			throw new ModelException("File " . $formPath . " Not found");
			return new BaseGrid();
		}
	}
}